package com.zheng.controller;

import com.alibaba.fastjson.JSON;
import com.zheng.mapper.MenuMapper;
import com.zheng.pojo.MainMenu;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@Api("LoginController用户登录控制类")
@RestController
public class MenuController {
    @Autowired
    MenuMapper menuMapper;
    @CrossOrigin
    @ApiOperation("获取菜单")
    @GetMapping("/menus")
    public String getAllMenus(){
        HashMap<String, Object> data = new HashMap<>();
        List<MainMenu> mainMenus = menuMapper.getMainMenus();
        data.put("data",mainMenus);
        data.put("status",200);
        String data_json = JSON.toJSONString(data);
        System.out.println("成功访问！！！");
        return data_json;
    }
}
